package fp.thetrainline.utils;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public enum ElementType {

	CLASS {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.className( id ) );
		}
	},
	CSS {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.cssSelector( id ) );
		}
	},
	ID {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.id( id ) );
		}
	},
	LINK {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.linkText( id ) );
		}
	},
	NAME {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.name( id ) );
		}
	},
	PARTIAL_LINK {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.partialLinkText( id ) );
		}
	},
	TAG_NAME {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.tagName( id ) );
		}
	},
	XPATH {
		@Override
		public WebElement findElement( WebDriver driver, String id ) {
			return driver.findElement( By.xpath( id ) );
		}
	};

	public abstract WebElement findElement( WebDriver driver, String id );
}
